﻿//***********************************************************************
// * Module:   MsjZaYlcsbaHandler
// * 作者:  曹荣芝
// * Modified: 2013-05-29
// * Purpose: Definition of the Class MsjZaYlcsbaHandler 业务逻辑处理Handler类
// ***********************************************************************/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using XWG.Framework.MSException;
using XWG.Framework.AuthUtility;
using XWG.Framework.AuthEntity;
using XWG.Framework.AuthSPConst;
using XWG.Framework.AuthBLL;
using XWG.JWBST.JWBSTEntity;
using XWG.JWBST.JWBSTSPConst;
using System.Web.Script.Serialization;
using System.Data;
using XWG.Framework.Query;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using XWG.JWBST.JWBSTBLL;
using XWG.Framework;
using System.Collections;
using JWBSTAPP.CommonClass;
namespace JWBSTAPP.AjaxServer
{
    /// <summary>
    /// MsjZaYlcsbaHandler 的摘要说明
    /// </summary>
    public class MsjZaYlcsbaHandler : JWBSTAPP.CommonClass.HttpHandlerBase, System.Web.SessionState.IRequiresSessionState
    {

        #region 添加记录
        /// <summary>
        /// 添加记录
        /// </summary>
        protected void AddRecord()
        {
            HttpContext context = HttpContext.Current;
            context.Response.ContentType = "text/plain";
            ResultModel mResultModel = new ResultModel(); //初始化返回类型
            try
            {

                MsjZaYlcsba mMsjZaYlcsba = new MsjZaYlcsba();
                mMsjZaYlcsba.Dwid = Guid.NewGuid().ToString(); //主键
                mMsjZaYlcsba.Hylb = context.Request.Form["selHylb"]; //行业类别(数据字典)
                mMsjZaYlcsba.Dwbh = context.Request.Form["texDwbh"]; //单位编号
                mMsjZaYlcsba.Dwmc = context.Request.Form["texDwmc"]; //单位(个人)名称
                mMsjZaYlcsba.Dwdz = context.Request.Form["texDwdz"]; //单位地址
                mMsjZaYlcsba.Sjzgbm = context.Request.Form["hidSjzgbm"]; //上级主管部门（选择）
                mMsjZaYlcsba.Jyxz = context.Request.Form["selJyxz"]; //经营性质(数据字典)
                mMsjZaYlcsba.Sfzh = context.Request.Form["texSfzh"]; //公民身份证号
                mMsjZaYlcsba.Frxm = context.Request.Form["texFrxm"]; //法人（负责人）
                mMsjZaYlcsba.Lxdh = context.Request.Form["texLxdh"]; //联系电话
                mMsjZaYlcsba.Zafzr = context.Request.Form["texZafzr"]; //治安负责人
                mMsjZaYlcsba.Yyzzzchm = context.Request.Form["texYyzzzchm"]; //经营范围-主营
                mMsjZaYlcsba.Gajgdjsj = context.Request.Form["texGajgdjsj"]; //经营范围-兼营
                mMsjZaYlcsba.Gajgjsr = context.Request.Form["radGajgjsr"]; //是否具备许可条件
                mMsjZaYlcsba.Qyjbr = context.Request.Form["radQyjbr"]; //材料是否齐全
                mMsjZaYlcsba.Cjsj = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); //创建时间(2013-05-28 09:13:01)
                mMsjZaYlcsba.Cjr = context.Session["UserID"].ToString(); //创建人(人员ID)
                //mMsjZaYlcsba.Cjrdw = context.Request.Form["texCjrdw"]; //创建单位(单位ID)
                //mMsjZaYlcsba.Xgr = context.Request.Form["texXgr"]; //修改人(人员ID)
                //mMsjZaYlcsba.Xgrdw = context.Request.Form["texXgrdw"]; //修改人单位(单位ID)
                //mMsjZaYlcsba.Xgsj = context.Request.Form["texXgsj"]; //修改时间(2013-05-28 09:13:01)
                mMsjZaYlcsba.Enabled = Enabled.TRUE; //是否有效（1有效，0无效）
                mMsjZaYlcsba.Movesign = "0"; //是否传输（1已，0未）

                mResultModel = MsjZaYlcsbaBLL.Insert(mMsjZaYlcsba, context.Session["UserID"], true); //新建操作
                context.Response.Write(JsonConvert.SerializeObject(mResultModel)); //序列化后返回
            }
            catch (Exception ex)
            {
                MSEx.DealErr(ex, "");
                mResultModel.ErrorCode = -9999;
                mResultModel.ISSucceed = false;
                context.Response.Write(JsonConvert.SerializeObject(mResultModel)); //序列化后返回
            }
        }
        #endregion

        #region 删除记录
        /// <summary>
        /// 删除记录
        /// </summary>
        protected void DeleteRecord()
        {

            HttpContext context = HttpContext.Current;
            context.Response.ContentType = "text/plain";
            ResultModel mResultModel = new ResultModel(); //声明返回类型
            string paramKey = context.Request.Params["id"];
            try
            {
                if (string.IsNullOrEmpty(paramKey))
                {
                    mResultModel.ErrorCode = -9991;
                    mResultModel.ISSucceed = false;
                    context.Response.Write(JsonConvert.SerializeObject(mResultModel)); //序列化后返回    
                    return;
                }
                MsjZaYlcsba mMsjZaYlcsba = new MsjZaYlcsba();
                if (!string.IsNullOrEmpty(paramKey))
                {
                    mResultModel = MsjZaYlcsbaBLL.Delete(paramKey, context.Session["UserID"], true); //删除对应的信息
                    context.Response.Write(JsonConvert.SerializeObject(mResultModel)); ; //序列化后返回
                }
            }
            catch (Exception ex)
            {
                MSEx.DealErr(ex, ""); //写入异常日志
                mResultModel.ErrorCode = -9999; //-9999代码是系统异常通用代码
                mResultModel.ISSucceed = false; //行为执行失败
                context.Response.Write(JsonConvert.SerializeObject(mResultModel)); //序列化后返回
            }

        }
        #endregion

        #region 修改记录
        /// <summary>
        /// 修改记录
        /// </summary>
        protected void EditRecord()
        {
            HttpContext context = HttpContext.Current;
            context.Response.ContentType = "text/plain";
            ResultModel mResultModel = new ResultModel(); //初始化返回类型
            MsjZaYlcsba mMsjZaYlcsba = new MsjZaYlcsba();

            string paramKey = context.Request.Params["id"];
            try
            {

                if (string.IsNullOrEmpty(paramKey))
                {
                    mResultModel.ErrorCode = -9991;
                    mResultModel.ISSucceed = false;
                    context.Response.Write(JsonConvert.SerializeObject(mResultModel)); //序列化后返回    
                    return;
                }
                mMsjZaYlcsba = MsjZaYlcsbaBLL.Load(paramKey); //根据键值获取实体信息
                if (mMsjZaYlcsba != null)
                {
                    mMsjZaYlcsba.Hylb = context.Request.Form["selHylb"]; //行业类别(数据字典)
                    mMsjZaYlcsba.Dwbh = context.Request.Form["texDwbh"]; //单位编号
                    mMsjZaYlcsba.Dwmc = context.Request.Form["texDwmc"]; //单位(个人)名称
                    mMsjZaYlcsba.Dwdz = context.Request.Form["texDwdz"]; //单位地址
                    mMsjZaYlcsba.Sjzgbm = context.Request.Form["hidSjzgbm"]; //上级主管部门（选择）
                    mMsjZaYlcsba.Jyxz = context.Request.Form["selJyxz"]; //经营性质(数据字典)
                    mMsjZaYlcsba.Sfzh = context.Request.Form["texSfzh"]; //公民身份证号
                    mMsjZaYlcsba.Frxm = context.Request.Form["texFrxm"]; //法人（负责人）
                    mMsjZaYlcsba.Lxdh = context.Request.Form["texLxdh"]; //联系电话
                    mMsjZaYlcsba.Zafzr = context.Request.Form["texZafzr"]; //治安负责人
                    mMsjZaYlcsba.Yyzzzchm = context.Request.Form["texYyzzzchm"]; //经营范围-主营
                    mMsjZaYlcsba.Gajgdjsj = context.Request.Form["texGajgdjsj"]; //经营范围-兼营
                    mMsjZaYlcsba.Gajgjsr = context.Request.Form["radGajgjsr"]; //是否具备许可条件
                    mMsjZaYlcsba.Qyjbr = context.Request.Form["radQyjbr"]; //材料是否齐全
                    //mMsjZaYlcsba.Cjsj = context.Request.Form["texCjsj"]; //创建时间(2013-05-28 09:13:01)
                    //mMsjZaYlcsba.Cjr = context.Request.Form["texCjr"]; //创建人(人员ID)
                    //mMsjZaYlcsba.Cjrdw = context.Request.Form["texCjrdw"]; //创建单位(单位ID)
                    mMsjZaYlcsba.Xgr = context.Session["UserID"].ToString(); //修改人(人员ID)
                    // mMsjZaYlcsba.Xgrdw = context.Request.Form["texXgrdw"]; //修改人单位(单位ID)
                    mMsjZaYlcsba.Xgsj = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"); //修改时间(2013-05-28 09:13:01)
                    mMsjZaYlcsba.Enabled = Enabled.TRUE; //是否有效（1有效，0无效）
                    mMsjZaYlcsba.Movesign = "0"; //是否传输（1已，0未）

                    mResultModel = MsjZaYlcsbaBLL.Update(mMsjZaYlcsba, context.Session["UserID"], true); //新建操作
                }
                else
                {
                    mResultModel.ErrorCode = -9990; //没有获取所需的信息，信息可能已被删除
                    mResultModel.ISSucceed = false;

                }
                context.Response.Write(JsonConvert.SerializeObject(mResultModel)); //序列化后返回
            }
            catch (Exception ex)
            {
                MSEx.DealErr(ex, "");
                mResultModel.ErrorCode = -9999;
                mResultModel.ISSucceed = false;
                context.Response.Write(JsonConvert.SerializeObject(mResultModel)); //序列化后返回
            }
        }
        #endregion

        #region 获取实体记录
        /// <summary>
        /// 获取实体记录
        /// </summary>
        protected void GetModel()
        {
            HttpContext context = HttpContext.Current;
            context.Response.ContentType = "text/plain";
            ResultModel mResultModel = new ResultModel(); //初始化返回类型
            string paramKey = context.Request.Params["id"];
            string json = "";
            try
            {
                MsjZaYlcsba mMsjZaYlcsba = new MsjZaYlcsba(); //声明实体
                if (!string.IsNullOrEmpty(paramKey))
                {
                    mMsjZaYlcsba = MsjZaYlcsbaBLL.Load(paramKey); //根据键值获取管理员
                    if (mMsjZaYlcsba != null)
                    {
                        json = JsonConvert.SerializeObject(mMsjZaYlcsba);
                    }
                    Hashtable hashtable = new Hashtable();
                    if (!string.IsNullOrEmpty(mMsjZaYlcsba.Sjzgbm))
                    {
                        AppOrganizatiOn query = AppOrganizatiOnBLL.Load(mMsjZaYlcsba.Sjzgbm);
                        if (query != null)
                        {
                            hashtable.Add("Sjzgbmmc", query.OrgnaName);
                        }
                    }
                    if (!string.IsNullOrEmpty(mMsjZaYlcsba.Jyxz))
                    {
                        QueryByPage pager = new QueryByPage();
                        SqlConditionList condition = new SqlConditionList();
                        condition.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, AppDictionaryConst.Columns.TypeId, "3e6b1651-53e7-4234-af23-fc985e1f10d4"), SqlLogicOper.AND_LOGIC);
                        condition.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, AppDictionaryConst.Columns.DictCode, mMsjZaYlcsba.Jyxz), SqlLogicOper.AND_LOGIC);
                        DataTable dt = pager.GetRecordByPage("*", condition.ToSql(), AppDictionaryConst.Columns.DictOrder, 0, 1, AppDictionaryConst.TableName, AppDictionaryConst.FieldKey, Sort.ASC).Tables[0];
                        if (dt != null && dt.Rows.Count > 0)
                        {
                            hashtable.Add("Jyxzmc", Convert.ToString(dt.Rows[0][AppDictionaryConst.Columns.DictMc]));
                        }
                    }
                    if (!string.IsNullOrEmpty(mMsjZaYlcsba.Hylb))
                    {
                        QueryByPage pager = new QueryByPage();
                        SqlConditionList condition = new SqlConditionList();
                        condition.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, AppDictionaryConst.Columns.TypeId, "1a66be3c-772c-4223-a4f7-1b5c0b20eaad"), SqlLogicOper.AND_LOGIC);
                        condition.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, AppDictionaryConst.Columns.DictCode, mMsjZaYlcsba.Hylb), SqlLogicOper.AND_LOGIC);
                        DataTable dt = pager.GetRecordByPage("*", condition.ToSql(), AppDictionaryConst.Columns.DictOrder, 0, 1, AppDictionaryConst.TableName, AppDictionaryConst.FieldKey, Sort.ASC).Tables[0];
                        if (dt != null && dt.Rows.Count > 0)
                        {
                            hashtable.Add("Hylbmc", Convert.ToString(dt.Rows[0][AppDictionaryConst.Columns.DictMc]));
                        }
                    }
                    if (mMsjZaYlcsba.Gajgjsr == "1")
                    {
                        hashtable.Add("Gajgjsrmc", "是");
                    }
                    else
                    {
                        hashtable.Add("Gajgjsrmc", "否");
                    }
                    if (mMsjZaYlcsba.Qyjbr == "1")
                    {
                        hashtable.Add("Qyjbrmc", "是");
                    }
                    else
                    {
                        hashtable.Add("Qyjbrmc", "否");
                    }
                    json = JsonString.AddAttribute(json, hashtable);
                }
            }
            catch (Exception ex)
            {
                MSEx.DealErr(ex, "");
                mResultModel.ErrorCode = -9990;
                mResultModel.ISSucceed = false;
                json = JsonConvert.SerializeObject(mResultModel);
            }
            context.Response.Write(json);
        }
        #endregion

        #region 获取数据
        /// <summary>
        /// 获取数据记录
        /// </summary>
        protected void QueryRecord()
        {
            TableMessage tm = new TableMessage();
            HearderMessage hm = new HearderMessage();
            List<HearderMessage> list = new List<HearderMessage>();
            HttpContext context = HttpContext.Current;
            context.Response.ContentType = "text/plain";
            string pageSize = context.Request.Form["pageSize"];
            string pageIndex = context.Request.Form["pageIndex"];
            string dwbh = context.Request.Form["texDWBH"] ?? string.Empty;
            string dwmc = context.Request.Form["texDWMC"] ?? string.Empty;
            if (String.IsNullOrEmpty(pageSize) || String.IsNullOrEmpty(pageIndex) || !AnyString.IsNumeric(pageSize) || !AnyString.IsNumeric(pageIndex))
                return;
            DataTable dtMsjZaYlcsba = new DataTable();
            int intPageSize = Convert.ToInt32(pageSize);
            int intPageIndex = Convert.ToInt32(pageIndex);
            QueryByPage Q = new QueryByPage();
            QueryInfo qInfo = new QueryInfo();
            SqlConditionList conditionList = new SqlConditionList();
            if (!string.IsNullOrEmpty(dwbh))
            {
                conditionList.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, MsjZaYlcsbaConst.Columns.Dwbh, dwbh), SqlLogicOper.AND_LOGIC);
            }
            if (!string.IsNullOrEmpty(dwmc))
            {
                conditionList.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.LIKE, MsjZaYlcsbaConst.Columns.Dwmc, "%" + dwmc + "%"), SqlLogicOper.AND_LOGIC);
            }
            string[] url = context.Request.UrlReferrer.ToString().Split('/');
            string strUrl = url.Last<string>();
            switch (strUrl)
            {
                case "MsjZaYlcsbaManagement.aspx": { //娱乐场所的
                    conditionList.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, MsjZaYlcsbaConst.Columns.Hylb, "YLCSBA"), SqlLogicOper.AND_LOGIC);
                }
                    break;
                case "MsjZaLgybaManagent.aspx": //旅馆业的
                    {
                        conditionList.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, MsjZaYlcsbaConst.Columns.Hylb, "LGYBA"), SqlLogicOper.AND_LOGIC);
                    }
                    break;
                case "MsjZaDdybaManagement.aspx": //典当业的
                    {
                        conditionList.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, MsjZaYlcsbaConst.Columns.Hylb, "DDYBA"), SqlLogicOper.AND_LOGIC);
                    }
                    break;
                case "MsjZaMybzwpManagement.aspx": //民用爆炸物品的
                    {
                        conditionList.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, MsjZaYlcsbaConst.Columns.Hylb, "MYBZWP"), SqlLogicOper.AND_LOGIC);
                    }
                    break;
                case "MsjZaBpyManagement.aspx": //爆破员的
                    {
                        conditionList.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, MsjZaYlcsbaConst.Columns.Hylb, "BPY"), SqlLogicOper.AND_LOGIC);
                    }
                    break;
                case "MsjZaQydyManagement.aspx": //枪支弹药运输的
                    {
                        conditionList.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, MsjZaYlcsbaConst.Columns.Hylb, "QZDYYSXK"), SqlLogicOper.AND_LOGIC);
                    }
                    break;
                case "MsjZaYhbzysxkManagement.aspx": //烟花爆竹的
                    {
                        conditionList.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, MsjZaYlcsbaConst.Columns.Hylb, "YHBZYSXK"), SqlLogicOper.AND_LOGIC);
                    }
                    break;
                case "MsjZaFjjshsManagement.aspx": //废旧金属回收备案的
                    {
                        conditionList.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, MsjZaYlcsbaConst.Columns.Hylb, "FJJSHSBA"), SqlLogicOper.AND_LOGIC);
                    }
                    break;
                case "MsjZaYzkzManagement.aspx": //印章刻制审批的
                    {
                        conditionList.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, MsjZaYlcsbaConst.Columns.Hylb, "YZKZSP"), SqlLogicOper.AND_LOGIC);
                    }
                    break;
                case "MsjZaBpzydwxkzManagement.aspx": //爆破作业单位许可证的
                    {
                        conditionList.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, MsjZaYlcsbaConst.Columns.Hylb, "BPZYDWXKZ"), SqlLogicOper.AND_LOGIC);
                    }
                    break;
                case "MsjZaSsbpzyxkManagement.aspx": //实施爆破作业许可
                    {
                        conditionList.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, MsjZaYlcsbaConst.Columns.Hylb, "BPZYXK"), SqlLogicOper.AND_LOGIC);
                    }
                    break;
                case "MsjZaQzdyxdxkManagement.aspx": //枪支弹药携带许可
                    {
                        conditionList.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, MsjZaYlcsbaConst.Columns.Hylb, "QZDYXDXK"), SqlLogicOper.AND_LOGIC);
                    }
                    break;
                case "MsjZaYhwhsqdjbManagement.aspx": //焰火晚会申请登记表
                    {
                        conditionList.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, MsjZaYlcsbaConst.Columns.Hylb, "YHWHXK"), SqlLogicOper.AND_LOGIC);
                    }
                    break;
                case "MsjZaWsbaManagement.aspx": //网上备案的
                    {
                        conditionList.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, MsjZaYlcsbaConst.Columns.Hylb, "WSBA"), SqlLogicOper.AND_LOGIC);
                    }
                    break;
                default:
                    {
                        conditionList.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.IS_NULL, MsjZaYlcsbaConst.Columns.Hylb,string.Empty), SqlLogicOper.AND_LOGIC);
                    }
                    break;
            }
            dtMsjZaYlcsba = Q.GetRecordByPage("*", conditionList.ToSql(), "", intPageSize, intPageIndex, MsjZaYlcsbaConst.QTableName, MsjZaYlcsbaConst.FieldKey, "").Tables[0];
            if (dtMsjZaYlcsba != null && dtMsjZaYlcsba.Rows.Count > 0)
            {
                for (int i = 0; i < dtMsjZaYlcsba.Columns.Count; i++)
                {
                    hm = new HearderMessage();
                    hm.name = dtMsjZaYlcsba.Columns[i].Caption;
                    list.Add(hm);
                }
                tm.Header = list;
                tm.data = dtMsjZaYlcsba;
                tm.totalCount = Convert.ToString((int)Q.RowCount);
            }
            string json = JsonConvert.SerializeObject(tm);
            context.Response.Write(json);
        }
        #endregion

        #region 获取备案类别ID(DropDownList)

        /// <summary>
        /// 获取备案类别ID(DropDownList)
        /// </summary>
        public void GetBaTypeId()
        {
            List<ControlID> selEntityId = new List<ControlID>();
            ControlID CID = new ControlID();
            QueryByPage Q = new QueryByPage();
            SqlConditionList sqllist = new SqlConditionList();
            sqllist.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, AppDictionaryConst.Columns.TypeId, "1a66be3c-772c-4223-a4f7-1b5c0b20eaad"), SqlLogicOper.AND_LOGIC);
            DataTable dtBusinessModelContent = Q.GetRecordByPage("*", sqllist.ToSql(), AppDictionaryConst.Columns.TypeId, 0, 1, AppDictionaryConst.TableName, AppDictionaryConst.FieldKey, Sort.ASC).Tables[0];
            if (dtBusinessModelContent != null && dtBusinessModelContent.Rows.Count > 0)
            {
                for (int i = 0; i < dtBusinessModelContent.Rows.Count; i++)
                {
                    CID = new ControlID();
                    CID.name = Convert.ToString(dtBusinessModelContent.Rows[i][AppDictionaryConst.Columns.DictMc]);
                    CID.value = Convert.ToString(dtBusinessModelContent.Rows[i][AppDictionaryConst.Columns.DictCode]);
                    selEntityId.Add(CID);
                }
            }
            string json = JsonConvert.SerializeObject(selEntityId);
            HttpContext.Current.Response.Write(json);
        }

        #endregion

        #region 获取经营性质字典(DropDownList)

        /// <summary>
        /// 获取经营性质字典ID(DropDownList)
        /// </summary>
        public void GetJyxz()
        {
            List<ControlID> selEntityId = new List<ControlID>();
            ControlID CID = new ControlID();
            QueryByPage Q = new QueryByPage();
            SqlConditionList sqllist = new SqlConditionList();
            sqllist.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, AppDictionaryConst.Columns.TypeId, "3e6b1651-53e7-4234-af23-fc985e1f10d4"), SqlLogicOper.AND_LOGIC);
            DataTable dtBusinessModelContent = Q.GetRecordByPage("*", sqllist.ToSql(), AppDictionaryConst.Columns.TypeId, 0, 1, AppDictionaryConst.TableName, AppDictionaryConst.FieldKey, Sort.ASC).Tables[0];
            if (dtBusinessModelContent != null && dtBusinessModelContent.Rows.Count > 0)
            {
                for (int i = 0; i < dtBusinessModelContent.Rows.Count; i++)
                {
                    CID = new ControlID();
                    CID.name = Convert.ToString(dtBusinessModelContent.Rows[i][AppDictionaryConst.Columns.DictMc]);
                    CID.value = Convert.ToString(dtBusinessModelContent.Rows[i][AppDictionaryConst.Columns.DictCode]);
                    selEntityId.Add(CID);
                }
            }
            string json = JsonConvert.SerializeObject(selEntityId);
            HttpContext.Current.Response.Write(json);
        }

        #endregion

        #region 获取单位信息列表

        /// <summary>
        /// 获取单位信息列表
        /// </summary>
        public void GetDwMessageList()
        {
            TableMessage tm = new TableMessage();
            HearderMessage hm = new HearderMessage();
            List<HearderMessage> list = new List<HearderMessage>();
            HttpContext context = HttpContext.Current;
            context.Response.ContentType = "text/plain";
            string pageSize = context.Request.Form["pageSize"];
            string pageIndex = context.Request.Form["pageIndex"];
            if (String.IsNullOrEmpty(pageSize) || String.IsNullOrEmpty(pageIndex) || !AnyString.IsNumeric(pageSize) || !AnyString.IsNumeric(pageIndex))
                return;
            string orgnaType = context.Request.Form["selOrgnaType"];
            string orgnaCode = context.Request.Form["texOrgnaCode"];
            string orgnaName = context.Request.Form["texOrgnaName"];
            string pOrganId = context.Request.Form["id"] ?? string.Empty;
            SqlConditionList conditionList = new SqlConditionList();
            if (!string.IsNullOrEmpty(pOrganId))
            {
                conditionList.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, AppOrganizatiOnConst.Columns.PorgnaId, pOrganId), SqlLogicOper.AND_LOGIC);
                conditionList.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, AppOrganizatiOnConst.Columns.OrgnaId, pOrganId), SqlLogicOper.OR_LOGIC);
            }
            if (!String.IsNullOrEmpty(orgnaType))
                conditionList.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, EntOrganizatiOnConst.Columns.OrgnaType, orgnaType), SqlLogicOper.AND_LOGIC);
            if (!String.IsNullOrEmpty(orgnaCode))
                conditionList.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.EQUAL, EntOrganizatiOnConst.Columns.OrgnaCode, orgnaCode), SqlLogicOper.AND_LOGIC);
            if (!String.IsNullOrEmpty(orgnaName))
                conditionList.AddLogic(new SqlConditionList.SqlCondition(SqlCompareOper.LIKE, EntOrganizatiOnConst.Columns.OrgnaName, "%" + orgnaName + "%"), SqlLogicOper.AND_LOGIC);

            string sql = conditionList.ToSql();

            DataTable dtAppOrganizatiOn = new DataTable();
            int intPageSize = Convert.ToInt32(pageSize);
            int intPageIndex = Convert.ToInt32(pageIndex);
            QueryByPage Q = new QueryByPage();
            QueryInfo qInfo = new QueryInfo();
            dtAppOrganizatiOn = Q.GetRecordByPage("*", sql, "", intPageSize, intPageIndex, AppOrganizatiOnConst.TableName, AppOrganizatiOnConst.FieldKey, "").Tables[0];
            if (dtAppOrganizatiOn != null && dtAppOrganizatiOn.Rows.Count > 0)
            {
                for (int i = 0; i < dtAppOrganizatiOn.Columns.Count; i++)
                {
                    hm = new HearderMessage();
                    hm.name = dtAppOrganizatiOn.Columns[i].Caption;
                    list.Add(hm);
                }
                tm.Header = list;
                tm.data = dtAppOrganizatiOn;
                tm.totalCount = Convert.ToString((int)Q.RowCount);
            }
            string json = JsonConvert.SerializeObject(tm);
            context.Response.Write(json);
        }
        #endregion

    }
}


